package com.hh.bidding.controller;

import com.hh.bidding.domain.BidTenderQuotation;
import com.hh.bidding.domain.BidTenderRules;
import com.hh.bidding.service.IBidTenderRulesService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 招标项目竞标规则表;(bid_tender_rules)表控制层
 * @author : http://www.chiner.pro
 * @date : 2025-9-11
 */
@RestController
@RequestMapping("/bidTenderRules")
public class BidTenderRulesController extends BaseController {
    @Resource
    private IBidTenderRulesService bidTenderRulesService;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @GetMapping("{id}")
    public AjaxResult queryById(@PathVariable("id") Integer id){
        return success(bidTenderRulesService.queryById(id));
    }

    /**
     * 分页查询
     *
     * @param bidTenderRules 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo paginQuery(BidTenderRules bidTenderRules){
        startPage();
        List<BidTenderRules> list = bidTenderRulesService.selectBidTenderRulesList(bidTenderRules);
        return getDataTable(list);
    }

    /**
     * 获取招标项目竞标规则详细信息
     */
    @GetMapping(value = "/getInfoBySid/{hid}/{sid}")
    public AjaxResult getInfo(@PathVariable("hid") Integer hid,@PathVariable("sid") Integer sid) {
        return success(bidTenderRulesService.selectBidTenderRulesByHidAndSid(hid,sid));
    }

    /**
     * 获取招标项目竞标规则详细信息
     */
    @GetMapping(value = "/findBiddingRuleBySid/{sid}")
    public AjaxResult findBiddingRuleBySid(@PathVariable("sid") Integer sid) {
        return success(bidTenderRulesService.selectBidTenderRulesBySid(sid));
    }

    /**
     * 新增数据
     *
     * @param bidTenderRules 实例对象
     * @return 实例对象
     */
    @PostMapping
    public AjaxResult add(@RequestBody BidTenderRules bidTenderRules){
        return toAjax(bidTenderRulesService.insert(bidTenderRules));
    }

    /**
     * 更新数据
     *
     * @param bidTenderRules 实例对象
     * @return 实例对象
     */
    @PutMapping
    public AjaxResult edit(@RequestBody BidTenderRules bidTenderRules){
        return toAjax(bidTenderRulesService.update(bidTenderRules));
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @DeleteMapping("/{id}")
    public AjaxResult deleteById(@PathVariable Integer id){
        return toAjax(bidTenderRulesService.deleteById(id));
    }
}
